﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProjectA.Controls;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;

namespace ProjectA.Modules.Configuracion.Usuarios
{
    public class cWindowUsuarios : cWindow
    {

        wsGeneral.WsGeneral wsGeneral;

        public int UsuarioSelected { get; set; }
        public cUsuario cUsuario;
        public cProyectos cProject;
        public cUsuario UserSelected { get; set; }
        public cConfiguracionUsuarios cConfigUsers;
        public DataTable dtProjUsers { get; set; }
        public DataSet dsUserInf { get; set; }
        public List<cProyectos> lProjectUser { get; set; }
        public List<cProyectoXUser> lProyXUser { get; set; }
        public List<cUsuario> ListUsuarios { get; set; }
        public List<cModulos> listModulesUser { get; set; }
        public List<cModulos> listAllModules { get; set; }
        public List<cProyectos> lProjectGeneral { get; set; }
        public List<cModulosPorUsuario> listModulosPorUsuario { get; set; }
        public eTabSelected TabSelected { get; set; }
        public int ProjectSelected { get; set; }
        public string Mode { get; set; }

        public enum eTabSelected { Usuarios, Proyectos, Modulos };
        
        
        public cWindowUsuarios(frmPrincipal frmPrincipal, Point pPoint, Size sSize)
        {
            this.frmPrincipal = frmPrincipal;
            this.BackColor = Color.Transparent;
            this.Location = pPoint;
            this.Size = sSize;
            wsGeneral = new wsGeneral.WsGeneral();
            InitializeComponent();
            InitComponent();
            LoadParameters();
            LoadAllListData();
            this.btTabInfoGeneral.Checked = true;
        }

        #region InformacionGeneral
        private void bSaveUserInfo_Click(object sender, EventArgs e)
        {
            try
            {
                SaveInfo();
                cConfigUsers.SaveUserInfo(UserSelected);
                ListBoxReload();
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo realizar la modificación!");
            }
        }

        // Eventos de los botones del BindingNavigator 
        private void tsbAddUser_Click(object sender, EventArgs e)
        {
            listBoxUsuarios.Items.Add("");
            listBoxUsuarios.SelectedIndex = listBoxUsuarios.Items.Count - 1;
            cbActiv.CheckState = CheckState.Checked;
            dtpFechaCreacion.Value = DateTime.Now;
            dtpFechaActualización.Visible = false;
            tbApellido1.Text = "";
            tbApellido2.Text = "";
            tbNombre1.Text = "";
            tbNombre2.Text = "";
            tbNombreUsuario.Text = "";
            tbContraseña.Text = "";
            cConfigUsers.Mode = "A";
        }
        private void tsbDelUser_Click(object sender, EventArgs e)
        {
            bool bResult = false;
            try
            {
                bResult = cConfigUsers.DeleteUser(UserSelected.UserID);
                if (bResult)
                {
                    ListBoxReload();
                }
            }
            catch (Exception)
            {
            }
        }
        private void tsbPreview_Click(object sender, EventArgs e)
        {
            if (0 < listBoxUsuarios.SelectedIndex)
            {
                listBoxUsuarios.SelectedIndex = listBoxUsuarios.SelectedIndex - 1;
            }
        }
        private void tsbNext_Click(object sender, EventArgs e)
        {
            if (listBoxUsuarios.Items.Count > listBoxUsuarios.SelectedIndex)
            {
                listBoxUsuarios.SelectedIndex = listBoxUsuarios.SelectedIndex + 1;
            }
        }
        #endregion

        #region Proyectos
        private void SaveProjectChanges_Click(object sender, EventArgs e)
        {
            try
            {
                cConfigUsers.GuardarProyectos(lProyXUser, UserSelected.UserID);
                MessageBox.Show("Modificacion exitosa!");
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo realizar la modificación!");
            }
        }
        #endregion

        #region Modulos
        private void bSaveModules_Click_1(object sender, EventArgs e)
        {
            try
            {
                List<int> lRowstodelete = new List<int>();
                string sTableName = "Tabla " + UserSelected.UserID;
                cConfigUsers.SaveModInDB(listModulosPorUsuario, UserSelected.UserID, ProjectSelected);
                MessageBox.Show("Modificacion exitosa!");
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo realizar la modificación!");
            }
        }
        #endregion

        private void LoadParameters()
        {
            cUsuario = new cUsuario();
            cProject = new cProyectos();
            cConfigUsers = new cConfiguracionUsuarios();
            ListUsuarios = new List<cUsuario>();
            lProjectUser = new List<cProyectos>();
            listModulesUser = new List<cModulos>();
            listAllModules = new List<cModulos>();
            listModulosPorUsuario = new List<cModulosPorUsuario>();
            lProjectGeneral = new List<cProyectos>();
            dsUserInf = new DataSet();
            dtProjUsers = new DataTable();

            lProyXUser = new List<cProyectoXUser>();
        }

        private void ListBoxReload()
        {
            DataSet dsData = new DataSet();
            cConfiguracionUsuarios cConfUsers = new cConfiguracionUsuarios();
            string sErrMess = "";
            wsGeneral.GetMemberShip(null, null, null, null, null, null, null, null, null, null, null, out dsData, out sErrMess);
            ListUsuarios = cConfUsers.GetAllUserInfo(dsData);
            listBoxUsuarios.SelectedItem = null;
            listBoxUsuarios.Items.Clear();
            for (int i = 0; i < ListUsuarios.Count; i++)
            {
                listBoxUsuarios.Items.Add(ListUsuarios[i].FirstName + " " + ListUsuarios[i].FirstLastName);
            }
        }

        private void SaveInfo()
        {
            if (cConfigUsers.Mode == "M")
            {
                UserSelected.UserID = UsuarioSelected;
            }
            else
            {
                UserSelected = new cUsuario();
            }
            UserSelected.FirstName = tbNombre1.Text;
            UserSelected.SecondName = tbNombre2.Text;
            UserSelected.FirstLastName = tbApellido1.Text;
            UserSelected.SecondLastName = tbApellido2.Text;
            UserSelected.UserName = tbNombreUsuario.Text;
            UserSelected.Password = tbContraseña.Text;
            UserSelected.CreationDate = dtpFechaCreacion.Value;
            UserSelected.UserState = cbActiv.Checked;
            UserSelected.Role = cbRole.SelectedItem.ToString();
        }

        private void LoadAllListData()
        {
            BindingSource customersBindingSource = new BindingSource();
            dtProjUsers = new DataTable();
            ListBoxReload();
            customersBindingSource.DataSource = ListUsuarios;
            bnUsuarios.BindingSource = customersBindingSource;
            cbRole.Items.Add("Administrador");
            cbRole.Items.Add("Usuario");
            lProjectGeneral = new List<cProyectos>();
            lProjectGeneral = cConfigUsers.LoadAllProjectInfo();
            dtProjUsers.Columns.Add("UserID", typeof(int));
            dtProjUsers.Columns.Add("ProjectID", typeof(int));
            dtProjUsers.Columns.Add("ProjectName", typeof(string));
            for (int a = 0; a < lProjectGeneral.Count; a++)
            {
                this.clbProjects.Items.Add(lProjectGeneral[a].Nombre);
            }
            for (int b = 0; b < ListUsuarios.Count; b++)
            {
                DataTable dtData = new DataTable();
                dtData.TableName = "Tabla " + ListUsuarios[b].UserID;
                dtData.Columns.Add("Project", typeof(int));
                dtData.Columns.Add("Module", typeof(int));
                dsUserInf.Tables.Add(dtData);
            }
        }

        public void LoadProjects(int iUserSelected)
        {
            lProyXUser = new List<cProyectoXUser>();
            lProjectUser = new List<cProyectos>();
            lProjectUser = cConfigUsers.LoadProjectsPerUser(iUserSelected);
            for (int a = 0; a < lProjectGeneral.Count; a++)
                clbProjects.SetItemChecked(a, false);
            lProyXUser = cConfigUsers.InfoProyectosSelec(iUserSelected, lProjectGeneral);
            for (int i = 0; i < lProyXUser.Count; i++)
                clbProjects.SetItemChecked((lProyXUser[i].Index), true);
        }

        public void loadModules(int iUserSelected, int iProjectSelected)
        {
            clbModulos.Items.Clear();
            listAllModules = new List<cModulos>();

            listAllModules = cConfigUsers.LoadAllModules();
            for (int a = 0; a < listAllModules.Count; a++)
            {
                clbModulos.Items.Add(listAllModules[a].Description);
            }
            listModulosPorUsuario = new List<cModulosPorUsuario>();
            listModulosPorUsuario = cConfigUsers.LoadModulesPerUser(iUserSelected);
            for (int a = 0; a < listAllModules.Count; a++)
            {
                for (int b = 0; b < listModulosPorUsuario.Count; b++)
                {
                    if (listAllModules[a].ID == listModulosPorUsuario[b].ModuleID && listModulosPorUsuario[b].ProjectID == iProjectSelected)
                    {
                        listModulesUser.Add(listAllModules[a]);
                        clbModulos.SetItemChecked(a, true);
                        break;
                    }
                }
            }
        }

        private void listBoxUsuarios_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox listB = (ListBox)sender;
            if (listB.Text != "")
            {
                UsuarioSelected = Convert.ToInt32(ListUsuarios[listB.SelectedIndex].UserID.ToString());
                tbNombre1.Text = ListUsuarios[listB.SelectedIndex].FirstName;
                tbNombre2.Text = ListUsuarios[listB.SelectedIndex].SecondName;
                tbApellido1.Text = ListUsuarios[listB.SelectedIndex].FirstLastName;
                tbApellido2.Text = ListUsuarios[listB.SelectedIndex].SecondLastName;
                tbNombreUsuario.Text = ListUsuarios[listB.SelectedIndex].UserName;
                tbContraseña.Text = ListUsuarios[listB.SelectedIndex].Password;
                dtpFechaCreacion.Enabled = false;
                dtpFechaCreacion.Value = ListUsuarios[listB.SelectedIndex].CreationDate;
                dtpFechaActualización.Value = ListUsuarios[listB.SelectedIndex].ModificationDate;
                cbActiv.Checked = ListUsuarios[listB.SelectedIndex].UserState;
                if (ListUsuarios[listB.SelectedIndex].Role == "Administrador")
                    cbRole.SelectedIndex = 0;
                else if (ListUsuarios[listB.SelectedIndex].Role == "Usuario")
                    cbRole.SelectedIndex = 1;
                UserSelected = ListUsuarios[listB.SelectedIndex];
                cConfigUsers.Mode = "M";
                LoadProjects(ListUsuarios[listB.SelectedIndex].UserID);
                clbModulos.Items.Clear();
                cbProyectoSelec.Text = "";
                cbProyectoSelec.Items.Clear();
                if (TabSelected == eTabSelected.Modulos)
                {
                    clbModulos.Items.Clear();
                    LoadProjects(UserSelected.UserID);
                    for (int c = 0; c < lProjectUser.Count; c++)
                    {
                        cbProyectoSelec.Items.Add(lProjectUser[c].Nombre);
                    }
                }
            }
        }

        private void clbProjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckedListBox CLB = (CheckedListBox)sender;
            if (UserSelected == null)
            {
                for (int i = 0; i < clbProjects.Items.Count; i++)
                    clbProjects.SetItemChecked(i, false);
                MessageBox.Show("Selecciona un usuario");
            }

            int iItemSelect = CLB.SelectedIndex;
            bool bIsCheck = CLB.GetItemChecked(iItemSelect);
            bool bEnter = false;
            if (!bIsCheck)
            {
                for (int a = 0; a < lProyXUser.Count; a++)
                {
                    if (lProyXUser[a].Index == iItemSelect)
                    {
                        lProyXUser[a].Estado = false;
                        bEnter = true;
                        break;
                    }
                }
                if (!bEnter)
                {
                    cProyectoXUser cPXU = new cProyectoXUser();
                    cPXU.ProyectoID = lProjectGeneral[iItemSelect].ID;
                    cPXU.ID = 0;
                    cPXU.Estado = false;
                    cPXU.Index = iItemSelect;
                    lProyXUser.Add(cPXU);
                }
            }
            else
            {
                for (int a = 0; a < lProyXUser.Count; a++)
                {
                    if (lProyXUser[a].Index == iItemSelect)
                    {
                        lProyXUser[a].Estado = true;
                        bEnter = true;
                        break;
                    }
                }
                if (!bEnter)
                {
                    cProyectoXUser cPXU = new cProyectoXUser();
                    cPXU.ProyectoID = lProjectGeneral[iItemSelect].ID;
                    cPXU.ID = 0;
                    cPXU.Estado = true;
                    cPXU.Index = iItemSelect;
                    lProyXUser.Add(cPXU);
                }
            }
        }

        private void clbModulos_SelectedIndexChanged(object sender, EventArgs e)
        {
            CheckedListBox CLB = (CheckedListBox)sender;
            int iModSelect = CLB.SelectedIndex;
            for (int i = 0; i < CLB.CheckedIndices.Count; i++)
            {
                if (CLB.CheckedIndices[i] == iModSelect)
                {
                    cModulosPorUsuario cModPorUsuario = new cModulosPorUsuario();
                    cModulos NewModule = new cModulos();
                    NewModule = listAllModules[iModSelect];
                    listModulesUser.Add(NewModule);
                    cModPorUsuario.ModuleID = NewModule.ID;
                    cModPorUsuario.UserID = UserSelected.UserID;
                    cModPorUsuario.ProjectID = ProjectSelected;
                    listModulosPorUsuario.Add(cModPorUsuario);
                    break;
                }
                else if (i == CLB.CheckedIndices.Count - 1)
                {
                    cModulosPorUsuario cModPorUsuario = new cModulosPorUsuario();
                    cModulos NewModule = new cModulos();
                    NewModule = listAllModules[iModSelect];
                    cModPorUsuario.ModuleID = NewModule.ID;
                    cModPorUsuario.UserID = UserSelected.UserID;
                    cModPorUsuario.ProjectID = ProjectSelected;
                    listModulesUser.Remove(NewModule);
                    listModulosPorUsuario.Remove(cModPorUsuario);
                    break;
                }
            }
            if (CLB.CheckedIndices.Count == 0)
            {
                cModulosPorUsuario cModPorUsuario = new cModulosPorUsuario();
                cModulos NewModule = new cModulos();
                NewModule = listAllModules[iModSelect];
                cModPorUsuario.ModuleID = NewModule.ID;
                cModPorUsuario.UserID = UserSelected.UserID;
                cModPorUsuario.ProjectID = ProjectSelected;
                listModulesUser.Remove(NewModule);
                listModulosPorUsuario.Remove(cModPorUsuario);
            }
        }

        private void cbProyectoSelec_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox ComboBox = (ComboBox)sender;
            loadModules(UserSelected.UserID, lProyXUser[ComboBox.SelectedIndex].ID);
            ProjectSelected = lProyXUser[ComboBox.SelectedIndex].ID;
        }

        private void btTabInfoGeneral_CheckedChanged(object sender, EventArgs e)
        {
            if (btTabInfoGeneral.Checked)
            {
                
                this.PanelModulos.Visible = false;
                this.PanelProyectos.Visible = false;
                btTabProyectos.Checked = false;
                btTabModulos.Checked = false;
                if (!this.PanelInformacionGeneral.Visible)
                    this.PanelInformacionGeneral.Visible = true;
                this.frmPrincipal.Update();
                btTabInfoGeneral.Enabled = false;
                btTabProyectos.Enabled = true;
                btTabModulos.Enabled = true;
                TabSelected = eTabSelected.Usuarios;
            }
        }

        private void btTabProyectos_CheckedChanged(object sender, EventArgs e)
        {
            if (btTabProyectos.Checked)
            {
                
                this.PanelModulos.Visible = false;
                this.PanelInformacionGeneral.Visible = false;
                btTabInfoGeneral.Checked = false;
                btTabModulos.Checked = false;
                if (!this.PanelProyectos.Visible)
                    this.PanelProyectos.Visible = true;
                this.frmPrincipal.Update();
                btTabInfoGeneral.Enabled = true;
                btTabProyectos.Enabled = false;
                btTabModulos.Enabled = true;
                TabSelected = eTabSelected.Proyectos;
            }
        }

        private void btTabModulos_CheckedChanged(object sender, EventArgs e)
        {
            if (btTabModulos.Checked)
            {
                
                this.PanelProyectos.Visible = false;
                this.PanelInformacionGeneral.Visible = false;
                btTabInfoGeneral.Checked = false;
                btTabProyectos.Checked = false;
                if (!this.PanelModulos.Visible)
                    this.PanelModulos.Visible = true;
                this.frmPrincipal.Update();
                btTabInfoGeneral.Enabled = true;
                btTabProyectos.Enabled = true;
                btTabModulos.Enabled = false;

                TabSelected = eTabSelected.Modulos;
                cbProyectoSelec.Items.Clear();
                lProyXUser = new List<cProyectoXUser>();
                if (UserSelected != null)
                    lProyXUser = cConfigUsers.GetProyectosPorUsuario(UserSelected.UserID);
                for (int c = 0; c < lProyXUser.Count; c++)
                {
                    cbProyectoSelec.Items.Add((lProyXUser[c].NombreProyecto));
                }
            }
        }

        private void InitComponent()
        {
            this.resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPrincipal));

            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            // Controles de la página
            // ----------------------------------------------------------------------------------------------------------------------------------------------------------

            this.btTabInfoGeneral = new cButtonToggle(new Point(338, 22), new Size(153, 39), new EventHandler(btTabInfoGeneral_CheckedChanged), Properties.Resources.bt_info_1, Properties.Resources.bt_info_2, Properties.Resources.bt_info_3, Properties.Resources.bt_info_4);
            this.btTabProyectos = new cButtonToggle(new Point(491, 22), new Size(153, 39), new EventHandler(btTabProyectos_CheckedChanged), Properties.Resources.bt_proyectos_usuarios_1, Properties.Resources.bt_proyectos_usuarios_2, Properties.Resources.bt_proyectos_usuarios_3, Properties.Resources.bt_proyectos_usuarios_4);
            this.btTabModulos = new cButtonToggle(new Point(644, 22), new Size(153, 39), new EventHandler(btTabModulos_CheckedChanged), Properties.Resources.bt_modulos_usuarios_1, Properties.Resources.bt_modulos_usuarios_2, Properties.Resources.bt_modulos_usuarios_3, Properties.Resources.bt_modulos_usuarios_4);
            
            // listBoxUsuarios
            this.listBoxUsuarios.Location = new Point(20,65);

            //PanelInformacionGeneral
            this.label_primerNombre = new cLabel(new Point(18, 9), new Size(115, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Primer Nombre");
            this.label_segundoNombre = new cLabel(new Point(18, 45), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Segundo Nombre");
            this.label_primerApellido = new cLabel(new Point(18, 81), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Primer Apellido");
            this.label_segundoApellido = new cLabel(new Point(18, 117), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Segundo Apellido");
            this.label_nombreUsuario = new cLabel(new Point(18, 153), new Size(145, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Nombre de Usuario");
            this.label_contraseña = new cLabel(new Point(18, 188), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Contraseña");
            this.label_fechaCreacion = new cLabel(new Point(18, 225), new Size(190, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Fecha de Creación");
            this.label_fechaActualizacion = new cLabel(new Point(18, 261), new Size(190, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Fecha de Actualización");
            this.label_estado = new cLabel(new Point(18, 297), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Estado");
            this.label_rol = new cLabel(new Point(18, 333), new Size(132, 18), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Rol");
            this.tbNombre1 = new cTextBox(new Point(235, 9), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.tbNombre2 = new cTextBox(new Point(235, 45), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.tbApellido1 = new cTextBox(new Point(235, 81), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.tbApellido2 = new cTextBox(new Point(235, 117), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.tbNombreUsuario = new cTextBox(new Point(235, 153), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.tbContraseña = new cTextBox(new Point(235, 188), new Size(208, 25), new Font("Arial", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), null, null);
            this.bSaveUserInfo = new cButton(new Point(171, 369), new Size(119, 34), new EventHandler(bSaveUserInfo_Click), Properties.Resources.bt_actualizar_1, Properties.Resources.bt_actualizar_2, Properties.Resources.bt_actualizar_3, Properties.Resources.bt_actualizar_4);
            // dtpFechaCreacion
            this.dtpFechaCreacion.Location = new Point(235,225);
            // dtpFechaActualización
            this.dtpFechaActualización.Location = new Point(235,261);
            // cbActiv
            this.cbActiv.Location = new Point(235,296);
            // cbRole
            this.cbRole.Location = new Point(235, 333);

            // PanelProyectos
            this.clbProjects.Location = new Point(20, 50);
            this.label2 = new cLabel(new Point(20, 14), new Size(242, 28), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Proyectos");
            this.bSaveProjectChanges = new cButton(new Point(301, 194), new Size(119, 34), new EventHandler(SaveProjectChanges_Click), Properties.Resources.bt_actualizar_1, Properties.Resources.bt_actualizar_2, Properties.Resources.bt_actualizar_3, Properties.Resources.bt_actualizar_4);
            
            // PanelModulos
            this.clbModulos.Location = new Point(20, 119);
            this.label1 = new cLabel(new Point(20, 14), new Size(242, 28), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Proyecto");
            this.label10 = new cLabel(new Point(20, 88), new Size(242, 28), new Font("Arial", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154))))), ContentAlignment.TopLeft, "Módulos");
            this.cbProyectoSelec.Location = new Point(20, 45);
            this.bSaveModules = new cButton(new Point(301, 194), new Size(119, 34), new EventHandler(bSaveModules_Click_1), Properties.Resources.bt_actualizar_1, Properties.Resources.bt_actualizar_2, Properties.Resources.bt_actualizar_3, Properties.Resources.bt_actualizar_4);


            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            // Windows de la página
            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            // PanelInformacionGeneral
            this.PanelInformacionGeneral.Location = new Point(338, 61);

            this.PanelInformacionGeneral.Controls.Add(this.label_primerNombre);
            this.PanelInformacionGeneral.Controls.Add(this.label_segundoNombre);
            this.PanelInformacionGeneral.Controls.Add(this.label_primerApellido);
            this.PanelInformacionGeneral.Controls.Add(this.label_segundoApellido);
            this.PanelInformacionGeneral.Controls.Add(this.label_nombreUsuario);
            this.PanelInformacionGeneral.Controls.Add(this.label_contraseña);
            this.PanelInformacionGeneral.Controls.Add(this.label_fechaCreacion);
            this.PanelInformacionGeneral.Controls.Add(this.label_fechaActualizacion);
            this.PanelInformacionGeneral.Controls.Add(this.label_estado);
            this.PanelInformacionGeneral.Controls.Add(this.label_rol);
            this.PanelInformacionGeneral.Controls.Add(this.tbNombre1);
            this.PanelInformacionGeneral.Controls.Add(this.tbNombre2);
            this.PanelInformacionGeneral.Controls.Add(this.tbApellido1);
            this.PanelInformacionGeneral.Controls.Add(this.tbApellido2);
            this.PanelInformacionGeneral.Controls.Add(this.tbNombreUsuario);
            this.PanelInformacionGeneral.Controls.Add(this.tbContraseña);
            this.PanelInformacionGeneral.Controls.Add(this.dtpFechaCreacion);
            this.PanelInformacionGeneral.Controls.Add(this.dtpFechaActualización);
            this.PanelInformacionGeneral.Controls.Add(this.cbActiv);
            this.PanelInformacionGeneral.Controls.Add(this.cbRole);
            this.PanelInformacionGeneral.Controls.Add(this.bSaveUserInfo);

            // PanelModulos
            this.PanelModulos.Location = new Point(338, 61);
            this.PanelModulos.Visible = false;

            this.PanelModulos.Controls.Add(this.clbModulos);
            this.PanelModulos.Controls.Add(this.label1);
            this.PanelModulos.Controls.Add(this.label10);
            this.PanelModulos.Controls.Add(this.cbProyectoSelec);
            this.PanelModulos.Controls.Add(this.bSaveModules);

            // PanelProyectos
            this.PanelProyectos.Location = new Point(338, 61);
            this.PanelProyectos.Visible = false;

            this.PanelProyectos.Controls.Add(this.clbProjects);
            this.PanelProyectos.Controls.Add(this.label2);
            this.PanelProyectos.Controls.Add(this.bSaveProjectChanges);

            this.Controls.Add(this.btTabInfoGeneral);
            this.Controls.Add(this.btTabProyectos);
            this.Controls.Add(this.btTabModulos);
            this.Controls.Add(PanelInformacionGeneral);
            this.Controls.Add(PanelModulos);
            this.Controls.Add(PanelProyectos);
            this.Controls.Add(this.listBoxUsuarios);


            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            // BindingNavigator bnUsuarios
            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            this.bnUsuarios = new BindingNavigator(new Container());
            this.bindingNavigatorMovePreviousItem = new ToolStripButton();
            this.bindingNavigatorSeparator = new ToolStripSeparator();
            this.bindingNavigatorPositionItem = new ToolStripTextBox();
            this.bindingNavigatorCountItem = new ToolStripLabel();
            this.bindingNavigatorSeparator1 = new ToolStripSeparator();
            this.bindingNavigatorMoveNextItem = new ToolStripButton();
            this.bindingNavigatorSeparator2 = new ToolStripSeparator();
            this.bindingNavigatorAddNewItem = new ToolStripButton();
            this.bindingNavigatorDeleteItem = new ToolStripButton();
            ((ISupportInitialize)(this.bnUsuarios)).BeginInit();
            this.bnUsuarios.SuspendLayout();
            // 
            // bnUsuarios
            // 
            this.bnUsuarios.AddNewItem = this.bindingNavigatorAddNewItem;
            this.bnUsuarios.AutoSize = false;
            this.bnUsuarios.CountItem = this.bindingNavigatorCountItem;
            this.bnUsuarios.DeleteItem = this.bindingNavigatorDeleteItem;
            this.bnUsuarios.Dock = System.Windows.Forms.DockStyle.None;
            this.bnUsuarios.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
            this.bnUsuarios.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.bindingNavigatorMovePreviousItem,
            this.bindingNavigatorSeparator,
            this.bindingNavigatorPositionItem,
            this.bindingNavigatorCountItem,
            this.bindingNavigatorSeparator1,
            this.bindingNavigatorMoveNextItem,
            this.bindingNavigatorSeparator2,
            this.bindingNavigatorAddNewItem,
            this.bindingNavigatorDeleteItem});
            this.bnUsuarios.Location = new Point(20, 26);
            this.bnUsuarios.MoveFirstItem = null;
            this.bnUsuarios.MoveLastItem = null;
            this.bnUsuarios.MoveNextItem = this.bindingNavigatorMoveNextItem;
            this.bnUsuarios.MovePreviousItem = this.bindingNavigatorMovePreviousItem;
            this.bnUsuarios.Name = "bnUsuarios";
            this.bnUsuarios.Padding = new System.Windows.Forms.Padding(0);
            this.bnUsuarios.PositionItem = this.bindingNavigatorPositionItem;
            this.bnUsuarios.Size = new Size(295, 30);
            this.bnUsuarios.Text = "bnUsuarios";
            // 
            // bindingNavigatorMovePreviousItem
            // 
            this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(Properties.Resources.bindingNavigatorMovePreviousItem_Image)); 
            this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";
            this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
            this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);
            this.bindingNavigatorMovePreviousItem.Text = "Mover anterior";
            this.bindingNavigatorMovePreviousItem.Click += new System.EventHandler(this.tsbPreview_Click);
            // 
            // bindingNavigatorSeparator
            // 
            this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
            this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);
            // 
            // bindingNavigatorPositionItem
            // 
            this.bindingNavigatorPositionItem.AccessibleName = "Posición";
            this.bindingNavigatorPositionItem.AutoSize = false;
            this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
            this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23);
            this.bindingNavigatorPositionItem.Text = "0";
            this.bindingNavigatorPositionItem.ToolTipText = "Posición actual";
            // 
            // bindingNavigatorCountItem
            // 
            this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
            this.bindingNavigatorCountItem.Size = new System.Drawing.Size(37, 22);
            this.bindingNavigatorCountItem.Text = "de {0}";
            this.bindingNavigatorCountItem.ToolTipText = "Número total de elementos";
            // 
            // bindingNavigatorSeparator1
            // 
            this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator";
            this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);
            // 
            // bindingNavigatorMoveNextItem
            // 
            this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(Properties.Resources.bindingNavigatorMoveNextItem_Image));
            this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
            this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
            this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);
            this.bindingNavigatorMoveNextItem.Text = "Mover siguiente";
            this.bindingNavigatorMoveNextItem.Click += new System.EventHandler(this.tsbNext_Click);
            // 
            // bindingNavigatorSeparator2
            // 
            this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator";
            this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);
            // 
            // bindingNavigatorAddNewItem
            // 
            this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(Properties.Resources.bindingNavigatorAddNewItem_Image));
            this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
            this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
            this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);
            this.bindingNavigatorAddNewItem.Text = "Agregar nuevo";
            this.bindingNavigatorAddNewItem.Click += new System.EventHandler(this.tsbAddUser_Click);
            // 
            // bindingNavigatorDeleteItem
            // 
            this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(Properties.Resources.bindingNavigatorDeleteItem_Image)); 
            this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
            this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
            this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);
            this.bindingNavigatorDeleteItem.Text = "Eliminar";
            this.bindingNavigatorDeleteItem.Click += new System.EventHandler(this.tsbDelUser_Click);
            ((System.ComponentModel.ISupportInitialize)(this.bnUsuarios)).EndInit();
            this.bnUsuarios.ResumeLayout(false);
            this.bnUsuarios.PerformLayout();

            this.Controls.Add(this.bnUsuarios);
        }

        // -----------------  Controles 
        public cButtonToggle btTabInfoGeneral { get; set; }
        public cButtonToggle btTabProyectos { get; set; }
        public cButtonToggle btTabModulos { get; set; }

        //PanelInformacionGeneral
        public cLabel label_primerNombre { get; set; }
        public cLabel label_segundoNombre { get; set; }
        public cLabel label_primerApellido { get; set; }
        public cLabel label_segundoApellido { get; set; }
        public cLabel label_nombreUsuario { get; set; }
        public cLabel label_contraseña { get; set; }
        public cLabel label_fechaCreacion { get; set; }
        public cLabel label_fechaActualizacion { get; set; }
        public cLabel label_estado { get; set; }
        public cLabel label_rol { get; set; }
        public cTextBox tbNombre1 { get; set; }
        public cTextBox tbNombre2 { get; set; }
        public cTextBox tbApellido1 { get; set; }
        public cTextBox tbApellido2 { get; set; }
        public cTextBox tbNombreUsuario { get; set; }
        public cTextBox tbContraseña { get; set; }
        public cButton bSaveUserInfo { get; set; }

        // PanelProyectos
        public cLabel label2 { get; set; }
        public cButton bSaveProjectChanges { get; set; }

        // PanelModulos
        public cLabel label1 { get; set; }
        public cLabel label10 { get; set; }
        public cButton bSaveModules { get; set; }

        //FormaPrincipal
        private frmPrincipal frmPrincipal { get; set; }

        //BindingNavigator
        private BindingNavigator bnUsuarios;
        private ToolStripButton bindingNavigatorAddNewItem;
        private ToolStripLabel bindingNavigatorCountItem;
        private ToolStripButton bindingNavigatorDeleteItem;
        private ToolStripButton bindingNavigatorMovePreviousItem;
        private ToolStripSeparator bindingNavigatorSeparator;
        private ToolStripTextBox bindingNavigatorPositionItem;
        private ToolStripSeparator bindingNavigatorSeparator1;
        private ToolStripButton bindingNavigatorMoveNextItem;
        private ToolStripSeparator bindingNavigatorSeparator2;

        public cWindow PanelInformacionGeneral;
        public cWindow PanelProyectos;
        public cDateTimePicker dtpFechaCreacion;
        public cDateTimePicker dtpFechaActualización;
        public cCheckBox cbActiv;
        public cComboBox cbRole;
        public cListBox listBoxUsuarios;
        private cWindow PanelModulos;
        public cCheckedListBox clbProjects;
        private cCheckedListBox clbModulos;
        public cComboBox cbProyectoSelec;
        private ComponentResourceManager resources;

        private void InitializeComponent()
        {
            this.PanelInformacionGeneral = new ProjectA.Controls.cWindow();
            this.PanelProyectos = new ProjectA.Controls.cWindow();
            this.PanelModulos = new ProjectA.Controls.cWindow();
            this.dtpFechaCreacion = new ProjectA.Controls.cDateTimePicker();
            this.dtpFechaActualización = new ProjectA.Controls.cDateTimePicker();
            this.cbActiv = new ProjectA.Controls.cCheckBox();
            this.cbRole = new ProjectA.Controls.cComboBox();
            this.listBoxUsuarios = new ProjectA.Controls.cListBox();
            this.clbProjects = new ProjectA.Controls.cCheckedListBox();
            this.clbModulos = new ProjectA.Controls.cCheckedListBox();
            this.cbProyectoSelec = new ProjectA.Controls.cComboBox();
            this.SuspendLayout();
            // 
            // PanelInformacionGeneral
            // 
            this.PanelInformacionGeneral.ImageBackGroundPage = null;
            this.PanelInformacionGeneral.Location = new System.Drawing.Point(0, 0);
            this.PanelInformacionGeneral.Margin = new System.Windows.Forms.Padding(0);
            this.PanelInformacionGeneral.Name = "PanelInformacionGeneral";
            this.PanelInformacionGeneral.Size = new System.Drawing.Size(460, 422);
            this.PanelInformacionGeneral.TabIndex = 0;
            // 
            // PanelProyectos
            // 
            this.PanelProyectos.ImageBackGroundPage = null;
            this.PanelProyectos.Location = new System.Drawing.Point(0, 0);
            this.PanelProyectos.Margin = new System.Windows.Forms.Padding(0);
            this.PanelProyectos.Name = "PanelProyectos";
            this.PanelProyectos.Size = new System.Drawing.Size(460, 422);
            this.PanelProyectos.TabIndex = 0;
            // 
            // PanelModulos
            // 
            this.PanelModulos.ImageBackGroundPage = null;
            this.PanelModulos.Location = new System.Drawing.Point(0, 0);
            this.PanelModulos.Margin = new System.Windows.Forms.Padding(0);
            this.PanelModulos.Name = "PanelModulos";
            this.PanelModulos.Size = new System.Drawing.Size(460, 422);
            this.PanelModulos.TabIndex = 0;
            // 
            // dtpFechaCreacion
            // 
            this.dtpFechaCreacion.Font = new System.Drawing.Font("Arial", 11.25F);
            this.dtpFechaCreacion.Format = System.Windows.Forms.DateTimePickerFormat.Short;
            this.dtpFechaCreacion.Location = new System.Drawing.Point(0, 0);
            this.dtpFechaCreacion.Margin = new System.Windows.Forms.Padding(0);
            this.dtpFechaCreacion.MinDate = new System.DateTime(2013, 1, 1, 0, 0, 0, 0);
            this.dtpFechaCreacion.Name = "dtpFechaCreacion";
            this.dtpFechaCreacion.Size = new System.Drawing.Size(208, 25);
            this.dtpFechaCreacion.TabIndex = 0;
            // 
            // dtpFechaActualización
            // 
            this.dtpFechaActualización.Font = new System.Drawing.Font("Arial", 11.25F);
            this.dtpFechaActualización.Format = System.Windows.Forms.DateTimePickerFormat.Short;
            this.dtpFechaActualización.Location = new System.Drawing.Point(0, 0);
            this.dtpFechaActualización.Margin = new System.Windows.Forms.Padding(0);
            this.dtpFechaActualización.MinDate = new System.DateTime(2013, 1, 1, 0, 0, 0, 0);
            this.dtpFechaActualización.Name = "dtpFechaActualización";
            this.dtpFechaActualización.Size = new System.Drawing.Size(208, 25);
            this.dtpFechaActualización.TabIndex = 0;
            // 
            // cbActiv
            // 
            this.cbActiv.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.cbActiv.AutoSize = true;
            this.cbActiv.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Bold);
            this.cbActiv.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(75)))), ((int)(((byte)(117)))), ((int)(((byte)(154)))));
            this.cbActiv.Location = new System.Drawing.Point(0, 0);
            this.cbActiv.Margin = new System.Windows.Forms.Padding(0);
            this.cbActiv.Name = "cbActiv";
            this.cbActiv.Size = new System.Drawing.Size(71, 22);
            this.cbActiv.TabIndex = 0;
            this.cbActiv.Text = "Activo";
            this.cbActiv.UseVisualStyleBackColor = true;
            // 
            // cbRole
            // 
            this.cbRole.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbRole.DropDownWidth = 208;
            this.cbRole.Font = new System.Drawing.Font("Arial", 11.25F);
            this.cbRole.FormattingEnabled = true;
            this.cbRole.Location = new System.Drawing.Point(0, 0);
            this.cbRole.Margin = new System.Windows.Forms.Padding(0);
            this.cbRole.Name = "cbRole";
            this.cbRole.Size = new System.Drawing.Size(208, 25);
            this.cbRole.TabIndex = 0;
            // 
            // listBoxUsuarios
            // 
            this.listBoxUsuarios.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.listBoxUsuarios.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F);
            this.listBoxUsuarios.FormattingEnabled = true;
            this.listBoxUsuarios.ItemHeight = 16;
            this.listBoxUsuarios.Location = new System.Drawing.Point(0, 0);
            this.listBoxUsuarios.Margin = new System.Windows.Forms.Padding(0);
            this.listBoxUsuarios.Name = "listBoxUsuarios";
            this.listBoxUsuarios.Size = new System.Drawing.Size(295, 420);
            this.listBoxUsuarios.TabIndex = 0;
            this.listBoxUsuarios.SelectedIndexChanged += new System.EventHandler(this.listBoxUsuarios_SelectedIndexChanged);
            // 
            // clbProjects
            // 
            this.clbProjects.CheckOnClick = true;
            this.clbProjects.Font = new System.Drawing.Font("Arial", 11.25F);
            this.clbProjects.FormattingEnabled = true;
            this.clbProjects.Location = new System.Drawing.Point(0, 0);
            this.clbProjects.Margin = new System.Windows.Forms.Padding(0);
            this.clbProjects.Name = "clbProjects";
            this.clbProjects.Size = new System.Drawing.Size(242, 355);
            this.clbProjects.TabIndex = 0;
            this.clbProjects.SelectedIndexChanged += new System.EventHandler(this.clbProjects_SelectedIndexChanged);
            // 
            // clbModulos
            // 
            this.clbModulos.CheckOnClick = true;
            this.clbModulos.Font = new System.Drawing.Font("Arial", 11.25F);
            this.clbModulos.FormattingEnabled = true;
            this.clbModulos.Location = new System.Drawing.Point(0, 0);
            this.clbModulos.Margin = new System.Windows.Forms.Padding(0);
            this.clbModulos.Name = "clbModulos";
            this.clbModulos.Size = new System.Drawing.Size(242, 276);
            this.clbModulos.TabIndex = 0;
            this.clbModulos.SelectedIndexChanged += new System.EventHandler(this.clbModulos_SelectedIndexChanged);
            // 
            // cbProyectoSelec
            // 
            this.cbProyectoSelec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbProyectoSelec.DropDownWidth = 242;
            this.cbProyectoSelec.Font = new System.Drawing.Font("Arial", 11.25F);
            this.cbProyectoSelec.FormattingEnabled = true;
            this.cbProyectoSelec.Location = new System.Drawing.Point(0, 0);
            this.cbProyectoSelec.Margin = new System.Windows.Forms.Padding(0);
            this.cbProyectoSelec.Name = "cbProyectoSelec";
            this.cbProyectoSelec.Size = new System.Drawing.Size(242, 25);
            this.cbProyectoSelec.TabIndex = 0;
            this.cbProyectoSelec.SelectedIndexChanged += new System.EventHandler(this.cbProyectoSelec_SelectedIndexChanged);
            this.ResumeLayout(false);

        }

     
    }
}
